package cn.lili.modules.serviceimpl;

import cn.lili.modules.entity.AppGive;
import cn.lili.modules.entity.AppUsersLikeVideos;
import cn.lili.modules.mapper.AppGiveMapper;
import cn.lili.modules.mapper.AppUsersLikeVideosMapper;
import cn.lili.modules.service.AppGiveService;
import cn.lili.modules.service.AppUsersLikeVideosService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author:xiangqian
 * @date: 2024/3/8 20:30
 */
@Service
public class AppUsersLikeVideosServiceImpl extends ServiceImpl<AppUsersLikeVideosMapper, AppUsersLikeVideos> implements AppUsersLikeVideosService {

    /**
     * 是否点赞查询
     *
     * @param openid 当前用户openID
     * @param id     当前作者ID
     * @return 0没有 1有
     */
    @Override
    public Long getAppUsersLikeVideosCount(String openid, String id) {
        if (openid == null) {
            return 0L;
        }
        LambdaQueryWrapper<AppUsersLikeVideos> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AppUsersLikeVideos::getUser_id, openid);
        queryWrapper.eq(AppUsersLikeVideos::getVideo_id, id);
        return this.count(queryWrapper);
    }
}
